﻿using ComputedTable.Version10;
using System.Collections.Generic;

namespace MortgageCalculator.Demo
{
    public static class AmortizationTableColumns
    {
        public const string PaymentNumber = "Payment Number";
        public const string PaymentDate = "Payment Date";
        public const string OpeningBalance = "Opening Balance";
        public const string Interest = "Interest";
        public const string Principal = "Principal";
        public const string PropertyTax = "Property Tax";
        public const string TotalPayments = "Total Payments";
        public const string ClosingBalance = "Closing Balance";
        public const string RemainingPayments = "Remaining Payments";

        public static string[] ColumnsWithOrderOfOperations { get; private set; }
        public static string[] ColumnsForCsvFile { get; private set; }

        static AmortizationTableColumns()
        {
            ColumnsWithOrderOfOperations = new string[] 
            {
                PaymentNumber,
                RemainingPayments,
                PropertyTax,
                Interest,
                Principal,
                OpeningBalance,
                ClosingBalance,
                PaymentDate,
                TotalPayments,                
            };

            ColumnsForCsvFile = new string[] 
            {
                PaymentNumber,
                PaymentDate,
                OpeningBalance,
                Interest,
                Principal,
                PropertyTax,
                TotalPayments,
                ClosingBalance,
                RemainingPayments
            };
        }
    }

    public class MortgageCalculatorOperationContext : OperationContext<int, string>
    {
        public IMortgageCalculatorInput Input { get; set; }
        public decimal TotalLoanPayments { get; set; }
        public decimal TotalInterestPaid { get; set; }
    }

    public static class ExtensionMethods
    {
        public static string ToStringCurrency(this decimal input)
        {
            return input.ToString("C");
        }

        public static string ToStringPercentage(this decimal input)
        {
            return input.ToString("P");
        }
    }
}
